import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace OrderExtensionApi {
  /** SPA订单扩展信息 */
  export interface OrderExtension {
    id: number; // 主键ID
    orderId?: number; // 关联trade_order表ID
    appointmentStartTime?: string | Dayjs; // 预约开始时间
    appointmentEndTime?: string | Dayjs; // 预约结束时间
    actualStartTime: string | Dayjs; // 实际开始时间
    actualEndTime: string | Dayjs; // 实际结束时间
    serviceDuration?: number; // 服务时长(分钟)
    roomId: number; // 房间ID
    technicianId: number; // 技师ID
    handCardId: number; // 手牌ID
    customerCount: number; // 客户数量
    serviceRequirements: string; // 服务要求
    specialRequests: string; // 特殊要求
    serviceStatus?: string; // 服务状态
    serviceNotes: string; // 服务备注
    customerNotes: string; // 客户备注
    internalNotes: string; // 内部备注
    interruptionReason: string; // 中断原因
    interruptionHandling: string; // 中断处理方案
    scope: string; // 权限范围
    scoperef: string; // 权限引用
    serviceQualityChecklist: string; // 服务质量检查清单
    technicianPerformanceNotes: string; // 技师表现备注
    roomPreparationStatus: string; // 房间准备状态
    customerArrivalConfirmation: boolean; // 客户到店确认
    serviceStartConfirmation: boolean; // 服务开始确认
    serviceCompletionConfirmation: boolean; // 服务完成确认
    technicianGender: string; // 技师性别要求
    roomType: string; // 房间类型要求
  }
}

/** 查询SPA订单扩展分页 */
export function getOrderExtensionPage(params: PageParam) {
  return requestClient.get<PageResult<OrderExtensionApi.OrderExtension>>('/spa/order-extension/page', { params });
}

/** 查询SPA订单扩展详情 */
export function getOrderExtension(id: number) {
  return requestClient.get<OrderExtensionApi.OrderExtension>(`/spa/order-extension/get?id=${id}`);
}

/** 新增SPA订单扩展 */
export function createOrderExtension(data: OrderExtensionApi.OrderExtension) {
  return requestClient.post('/spa/order-extension/create', data);
}

/** 修改SPA订单扩展 */
export function updateOrderExtension(data: OrderExtensionApi.OrderExtension) {
  return requestClient.put('/spa/order-extension/update', data);
}

/** 删除SPA订单扩展 */
export function deleteOrderExtension(id: number) {
  return requestClient.delete(`/spa/order-extension/delete?id=${id}`);
}


/** 导出SPA订单扩展 */
export function exportOrderExtension(params: any) {
  return requestClient.download('/spa/order-extension/export-excel', { params });
}

